/***************************************************************************
 *   Copyright (C) 2008 by MacJariel                                       *
 *   echo "badmailet@gbalt.dob" | tr "edibmlt" "ecrmjil"                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef SERVERTESTER_H
#define SERVERTESTER_H

#include <QtGui>
#include <QtNetwork>

class ShortcutButton: public QPushButton {
    Q_OBJECT;
public:
    ShortcutButton(QString title, QString content);
    static void init(QLayout*, QTextEdit*, QPushButton*);

private:
    QString m_title;
    QString m_content;
    static QLayout* smp_layout;
    static QTextEdit* smp_textEdit;
    static QPushButton* smp_sendButton;
public slots:
    void updateTextEdit();
};


class ServerTester: public QWidget {
    Q_OBJECT
public:
    ServerTester(QWidget *parent = 0);

private:
    void initButtons();

private:
    bool         m_connected;
    QTcpSocket   m_tcpSocket;
    QLineEdit   *mp_lineEditAddress;
    QLineEdit   *mp_lineEditPort;
    QPushButton *mp_pushButtonConnect;
    QPushButton *mp_pushButtonSendXml;

    QHBoxLayout *mp_layoutConnect;
    QHBoxLayout *mp_layoutXmlInput;
    QGridLayout *mp_layoutButtons;
    QVBoxLayout *mp_layoutLeftSide;
    QVBoxLayout *mp_layoutRightSide;
    QHBoxLayout *mp_layoutMain;

    QTextEdit   *mp_textEditViewXml;
    QTextEdit   *mp_textEditInputXml;

public slots:
    void connectClicked();
    void tcpSocketError();
    void connected();
    void disconnected();
    void sendClicked();
    void incomingData();
};




#endif
